home *** CD-ROM | disk | FTP | other *** search
/ SGI Enlighten DSM 3.1 / SGI EnlightenDSM 3.1.iso / EXTRA / ENL_LOAD.SH < prev   
Linux/UNIX/POSIX Shell Script  |  1999-04-16  |  2KB  |  78 lines

  1. #!/bin/sh
  2. #
  3. # Script: enl_load.sh
  4. #
  5. # This script loads data from flat files created with enl_dump.sh into
  6. # an existing enlighten database.
  7. # To use this script:
  8. # 1. It must be run by user "dbenl"
  9. # 2. There must not be any open connections to the database; therefore, the EMD
  10. #    should not be running. To ensure that no events data is lost, PEP
  11. #    should not be running either. The events daemons will cache data until
  12. #    PEP is reachable again. PEP does not cache data.
  13. #
  14. # (c) 1996 ENlighten Software Solutions, Inc.
  15. # All Rights Reserved.
  16. #
  17.  
  18. curr_dir=`pwd`
  19. command_file=ENL_CMDS.TXT
  20.  
  21. echo "This script will load data from flat files created with 'ENL_DUMP.SH'"
  22. echo "into an existing ENlighten database."
  23. echo ""
  24. echo "Enter the full path name of the directory which contains"
  25. echo "the 'enlighten.exp' sub-directory created with 'ENL_DUMP.SH' or enter"
  26. echo "q to quit:"
  27.  
  28. while true
  29. do
  30.     read indir
  31.  
  32.     if [ "$indir" = "q" -o "$indir" = "Q" ] ; then
  33.         exit 1
  34.     fi
  35.  
  36.     if [ ! "$indir" ] ; then
  37.         echo "Enter the full path name of the directory which contains"
  38.         echo "the 'enlighten.exp' sub-directory created with 'ENL_DUMP.SH'"
  39.         echo "or enter q to quit:"
  40.     elif [ ! -d "$indir" ] ; then
  41.         echo "Directory $indir does not exist."
  42.         echo "Please re-enter or type 'q' to exit:"
  43.     elif [ ! -d "$indir"/enlighten.exp ] ; then
  44.         echo "$indir/enlighten.exp does not exist."
  45.         echo "Are you \"$indir\" is correct?"
  46.         echo "Re-enter or type 'q' to exit:"
  47.     else
  48.         break
  49.     fi
  50. done
  51.  
  52. if [ ! -f $curr_dir/$command_file ] ; then
  53.     echo "Unable to find $curr_dir/$command_file"
  54.     echo "Please copy the file \"$command_file\" to your current working"
  55.     echo "directory and try again."
  56.     exit 1
  57. fi
  58.  
  59. echo "Copying file \"$command_file\" to $indir/enlighten.exp..."
  60. cp $curr_dir/$command_file $indir/enlighten.exp
  61.  
  62. if [ ! -f $indir/enlighten.exp/$command_file ] ; then
  63.     echo "Unable to copy \"$command_file\""
  64.     echo "Aborting..."
  65.     exit 1
  66. fi
  67.  
  68. echo "delete from pool_tbl;delete from pool_entry_tbl;delete from prefer_tbl;delete from auth_tbl;delete from template_tbl;delete from expire_tbl;commit;" > tmp.sql
  69. dbaccess enlighten tmp 2> $curr_dir/enl_load.log
  70. rm tmp.sql
  71.  
  72. echo "Extracting data from $indir/enlighten.exp..."
  73.  
  74. cd $indir/enlighten.exp
  75. dbload -c $command_file -d enlighten -l $curr_dir/enl_load.log -e 100 1> /dev/null
  76. echo "Done loading data. Errors, if any, will be found in $curr_dir/enl_load.log
  77.             
  78.